<template>
	<view class="content">
		<view class="search-box">
			<uni-search-bar @confirm="search"  v-model="searchValue" @input="input" @cancel="cancel" @clear="clear" placeholder="输入产品名称">
			</uni-search-bar>
		</view>
		<view class="table-box" >
			<view :class="tableIndex==index?'tableChange':'table'" v-for="(item,index) in tableList" :key="index" @click="tableChange(item,index)">
				<text>{{item.title}}</text>
				<view class="border">
				</view>
			</view>
		</view>
		<z-paging ref="paging" v-model="dataList" :default-page-size="row" @onRefresh="onRefresh" @query="getList"
			auto-show-system-loading auto-show-back-to-top>
			<view class="" style="padding: 190rpx 20rpx 20rpx 20rpx;">
		<view class="list-box" v-for="(item,index) in dataList" :key="index">
			<view class="top-box">
				<view class="tiem-box" v-if="item.projectName">
					{{item.projectName}}
				</view>
				<view class="status-box">
					<view class="item-box" v-if="item.status == 2">
						已完成
					</view>
					<view class="item-box" v-if="item.status == 1">
						未完成
					</view>
				</view>
			</view>
			<view class="xian"></view>
			<view class="title-box" v-if="item.projectCode">
				{{item.projectCode}}
			</view>
			<view class="info-box">
				<view class="info-item" v-if="item.name">
					<view class="info-item-title">
						工序名称
					</view>
					<view class="info-item-text">
						{{item.name}}
					</view>
				</view>
				<view class="info-item" v-if="item.count">
					<view class="info-item-title">
						分配数量
					</view>
					<view class="info-item-text">
						{{item.count}}
					</view>
				</view>
				<view class="info-item" v-if="item.money">
					<view class="info-item-title">
						已完成数量
					</view>
					<view class="info-item-text">
						{{item.remainCount}}
					</view>
				</view>
			</view>
			<view class="text-box" v-if="item.goodsName">
				产品名称：{{item.goodsName}}
			</view>
			<view class="text-box" v-if="item.goodsCode">
				产品编码：{{item.goodsCode}}
			</view>
			<view class="text-box" v-if="item.goodsModel">
				产品型号：{{item.goodsModel}}
			</view>
			<view class="text-box" v-if="item.goodsBrand">
				型号明细：{{item.goodsBrand}}
			</view>
			<view class="text-box" v-if="item.planEndTime">
				计划完成时间：{{item.planEndTime}}
			</view>
			<view class="text-box" v-if="item.remark">
				备注：{{item.remark}}
			</view>
			<view class="xian"></view>
			<view class="bnt-box">
				<view class="bnt-big-box">
					<view class="bnt1" @click="goto1(item)">
						巡检
					</view>
				</view>
			</view>
		</view>
		</view>
		</z-paging>
	</view>
</template>

<script>
	import config from '@/config'
	import {
		goodsSaledoGongxuUserList,
		removeUpdate
	} from "@/api/system/index"
	const baseUrl = config.baseUrl
	export default {
		data() {
			return {
				name: '',
				text: '',
				searchValue: '',
				tableList: [{
						title: '全部',
						status: '',
						state: 0,
					},
					{
						title: '已完成',
						status: 0,
						state: 1
					},
					{
						title: '未完成',
						status: 1,
						state: 2
					}
				], //table列表
				row: 10,
				tabList: [],
				tableIndex: 0, //当前选择
				dataList: [],
				status:'',
			}
		},
		onLoad(e) {
			this.tableIndex = e.tableIndex
			this.status = this.tableList[e.tableIndex].status
		},
		methods: {
			goto1(e) {
				uni.navigateTo({
				  url: '/pagesA/pollingList/addPolling/index?info=' + JSON.stringify(e)
				});
			},
			deleteBnt(e) {
				var add = e
				uni.showModal({
					title: '提示',
					content: '确定删除报工吗？',
					success :(res)=> {
						if (res.confirm) {
							removeUpdate(add.id).then(res=>{
								this.$refs.paging.reload()
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			// 当页面滚动到底部事件被触发
			onReachBottom() {
				// 通知z-paging滚动到底部了，z-paging会进行相应的处理，例如加载更多数据
				this.$refs.paging.pageReachBottom();
			},
			// 下拉刷新被触发
			onRefresh() {
				// 告知z-paging下拉刷新结束，这样才可以开始下一次的下拉刷新
				setTimeout(() => {
					this.$tools.toast('刷新成功～')
				}, 500)
			},
			// @query所绑定的方法不要自己调用！！需要刷新列表数据时，只需要调用this.$refs.paging.reload()即可
			getList(pageNum, pageSize) {
				goodsSaledoGongxuUserList({
					pageNum,
					pageSize,
					status :this.status,
					goodsName:this.searchValue
				}).then(res => {
					this.$refs.paging.complete(res.rows);
					console.log(res, '这是什么')
				})
			},
			inputDialogToggle(e) {
				this.text = e
				this.$refs.inputDialog.open()
			},
			tableChange(item, index) {
				this.tableIndex = index
				this.status = item.status
				this.$refs.paging.reload()
			},
			goto() {
				uni.navigateTo({
					url: '/pagesA/remit/details/index'
				})
			},
			goto2() {
				uni.navigateTo({
					url: '/pagesA/remit/commodity/index'
				})
			},
			search(res) {
				this.$refs.paging.reload()
			},
			cancel() {
				this.$refs.paging.reload()
			}
			
		}

	}
</script>

<style lang="scss">
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding-left: 20rpx;
		padding-right: 20rpx;

		.table-box {
			width: 750rpx;
			position: sticky;
			top: 0;
			z-index: 2;
			background: #ffffff;
			display: flex;
			justify-content: space-around;

			.table {
				padding: 23rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #666666;
				display: flex;
				flex-direction: column;
				align-items: center;

				.border {
					margin-top: 10rpx;
					width: 32rpx;
					height: 4rpx;
				}
			}

			.tableChange {
				padding: 23rpx 0;
				font-size: 28rpx;
				font-weight: 400;
				color: #333333;
				display: flex;
				flex-direction: column;
				align-items: center;

				.border {
					margin-top: 10rpx;
					width: 32rpx;
					height: 4rpx;
					background: #8295BC;
				}
			}
		}

		.search-box {
			width: 750rpx;
			height: 103rpx;
			background: #FFFFFF;
			z-index: 99;
		}

		.list-box {
			padding-left: 20rpx;
			padding-right: 20rpx;
			margin-top: 20rpx;
			border-radius: 8rpx;
			background: #FFF;

			.top-box {
				display: flex;
				align-items: center;
				padding: 20rpx 0rpx;

				.tiem-box {
					color: #999;
					font-size: 24rpx;
				}

				.status-box {
					margin-left: auto;
					display: flex;
					align-items: center;

					.item-box {
						padding: 4rpx 12rpx;
						width: 96rpx;
						height: 42rpx;
						border-radius: 10rpx;
						background: #F5F7FB;
						color: #8295BC;
						font-size: 24rpx;
					}
				}
			}

			.xian {
				width: 662rpx;
				border-bottom: 1px solid #EAEAEA;
			}

			.title-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #333;
				font-size: 28rpx;
				font-weight: bold;
			}

			.info-box {
				display: flex;
				align-items: center;
				border-radius: 8rpx;
				background: #F5F7FB;
				padding-top: 30rpx;
				padding-bottom: 30rpx;

				.info-item {
					flex: 1;
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;

					.info-item-title {
						color: #999;
						font-size: 24rpx;
					}

					.info-item-text {
						margin-top: 8rpx;
						color: #333;
						font-size: 28rpx;
						font-weight: bold;
					}
				}
			}

			.text-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;
				color: #999;
				font-size: 24rpx;
			}

			.bnt-box {
				padding-top: 20rpx;
				padding-bottom: 20rpx;

				.bnt-big-box {
					display: flex;
					justify-content: flex-end;
					align-items: center;

					.bnt {
						margin-right: 20rpx;
						display: flex;
						align-items: center;
						border-radius: 10rpx;
						background: #F5F7FB;
						padding: 15rpx 30rpx 15rpx 30rpx;
						color: #4D8987;
						font-size: 24rpx;
					}
					.bnt1 {
						margin-right: 20rpx;
						display: flex;
						align-items: center;
						border-radius: 10rpx;
						background: #4D8987;
						padding: 15rpx 30rpx 15rpx 30rpx;
						color: #ffffff;
						font-size: 24rpx;
					}
				}
			}
		}
	}
</style>